package bishi;

public class test1 {
	public static void main(String args){
		
	}
	public static String unpress(String str){
		  if(str == null) return null;
		  String res = "";
		  String temp = "";
		  int num = 1;
		  for(int i = 0;i < str.length();i++){
		   char c = str.charAt(i);
		   if(Character.isLetter(c)){
		    temp += c;
		   }
		   else if(Character.isDigit(c)){
		    num = c - '0';
		    while(Character.isDigit(str.charAt(i + 1))){
		     num = 10 * num + str.charAt(i + 1) - '0';
		     i++;
		    }

		   }else if(c == '['){
		    int count = 0;
		    int index = i;
		    while(true){
		     if(str.charAt(i) == '['){
		      count++;
		     }
		     
		     if(str.charAt(i) == ']'){
		      count--;
		      if(count == 0)
		       break;
		     }
		     i++;
		    }
		    String partRes = unpress(str.substring(index + 1,i));
		    temp += partRes;
		   }
		   if(i == str.length() - 1){

		    for(int j = 0;j < num;j++)
		     res += temp;
		    num = 1;
		   }
		  }
		  return res;
		 }
}
